package com.ruoyi.web.controller.system;

import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.json.JSON;
import com.ruoyi.system.domain.Demo01Config;
import com.ruoyi.system.service.Demo01Service;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.spring.web.json.Json;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/demo/demo01")
public class Demo01Controller {

    @Autowired
    private Demo01Service demo01Service;

//    @RequiresPermissions("demo:demo01:edit")
//    @GetMapping("/edit/{configId}")
//    public List<Demo01Config> edit(@PathVariable("configId") Long configId, ModelMap mmap) {
//        List<Demo01Config> demo01Configs = demo01Service.selectAllInfo();
//        return demo01Configs;
//    }

//    @RequiresPermissions("demo:demo01:selectInfoById")
    @GetMapping("/selectInfoById/{configId}")
    public String selectInfoById(@PathVariable("configId") Long configId, ModelMap mmap) {
        log.info("走到了 3333333333333");
        Demo01Config demo01Configs = demo01Service.selectInfoById(configId);
        String o = JSONObject.toJSONString(demo01Configs);
        return o;
    }

    //http://localhost/demo/demo01/selectInfoAll
    @GetMapping("/selectInfoAll")
    public String selectInfoAll() {
        log.info("走到了 3333333333333");
        List<Demo01Config> demo01Configs = demo01Service.selectInfoAll();
        String o = JSONObject.toJSONString(demo01Configs);
        return o;
    }

//    @PostMapping("/updateInfoById")
//    public void updateInfoById(Demo01Config demo01Config) {
//        demo01Service.updateInfoById(demo01Config);
//    }

}
